#pragma once

#include <string>
using namespace std;

#include "pugixml/pugixml.hpp"

#include "topcvt_cross_platform.hpp"
#include "topcvt_policy_factory.hpp"
#include "topcvt_exception.hpp"
#include "topcvt_buffer.hpp"
#include "topcvt_policycontext.hpp"
#include "topcvt_exprparser.hpp"
#include "topcvt_policyhelper.hpp"
#include "topcvt_object.hpp"

namespace topcvt
{
	class UnpackImp
	{
	protected:
		ByteBuffer& m_message;
		map<string,string> m_atx;
	public:
		UnpackImp(ByteBuffer& message);
		virtual ~UnpackImp(){};

		inline map<string,string>& getAtx() { return m_atx;};

		virtual void checkElementCfgValid(AttributeableCfg& attributeableCfg);
		virtual string unpackField(pugi::xml_node& node, FieldCfg& cfg, PolicyContext& ctx) { return string(); };

		virtual PolicyContext& unpackPolicy(PolicyContext& PolicyContext, PolicyCfg& policyCfg);
		virtual void unpack(pugi::xml_node& node, PolicyContext& ctx);
		virtual void unpackPolicy(pugi::xml_node& node, PolicyCfg& cfg,PolicyContext& ctx,ByteBuffer& message);
		virtual void unpackInclude(pugi::xml_node& node, IncludeCfg& cfg,PolicyContext& ctx);
		virtual void unpackStruct(pugi::xml_node& node, StructCfg& cfg,PolicyContext& ctx);
		virtual void unpackLoop(pugi::xml_node& node, LoopCfg& cfg,PolicyContext& ctx);
		virtual void unpackSwitch(pugi::xml_node& node, SwitchCfg& cfg,PolicyContext& ctx);
		virtual void unpackCase(pugi::xml_node& node, CaseCfg& cfg,PolicyContext& ctx);
	};
};
